home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6407 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: qualcomm.com!usenet
  2. From: nabbasi@qualcomm.com (Nasser Abbasi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: VMS Descriptors in C++?
  5. Date: 8 Feb 1996 00:01:48 GMT
  6. Organization: QUALCOMM
  7. Message-ID: <4fbehc$sdl@qualcomm.com>
  8. References: <1996Feb7.143723.25305@alw.nih.gov>
  9. NNTP-Posting-Host: nabbasi.qualcomm.com
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.14
  12.  
  13. In article <1996Feb7.143723.25305@alw.nih.gov>, 
  14. systex@BALROG.NCI.NIH.GOV210-7701 says...
  15.  
  16. >/*
  17. > *      A simple macro to construct a string descriptor:
  18. > */
  19. >#define $DESCRIPTOR(name,string)        struct dsc$descriptor_s name = { 
  20. sizeof(string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
  21. >
  22. >An example of a call to the macro would be:
  23. >
  24. >    
  25. >    dsc$descriptor_s dsc;
  26. >    $DESCRIPTOR(dsc, "XYZ");
  27. >    status = SYS$GETDVI (0, 0, &dsc, &itmlst[0], &iosb, 0, 0, 0);
  28. >
  29. >The $DESCRIPTOR syntax only takes literal character array and not a 
  30. Class
  31. >strings.  If I create a subroutine to call the system service by passing 
  32. >literal character array, that works fine.  However, if I pass a string 
  33. object,
  34. >then the $DESCRIPTOR fails.
  35. >
  36.  
  37. Hello,
  38.  
  39. You need to have a second look at the dsc$descriptor macro.
  40.  
  41. It seems to me that "XYZ" is the what is passed to macro with the 
  42. name "string" , and then you doing sizeof(string)-1 , which will expand
  43. to sizeof("XYZ") -1  . That should be strlen(string) -1.
  44.  
  45. If I remember there are different descriptors for different types of
  46. strings. you might want to use the descriptor that uses the strlen(), not
  47. sizeof().
  48.  
  49. And the dsc$descriptor do not ONLY take literal characters, it can take
  50. pointer to buffer, you just need to make sure you use the correct macro.
  51. (the last parameter in the macro is the address of the buffer)
  52.  
  53. Also look at the type of buffer you are using. there are macros
  54. for static buffers, there are ones for dynamic (heap) buffers, That is
  55. what the second parameter in the macro is for . for example DSC$K_DTYPE_T
  56. means Dynamic buffer. You need to know what each one of these parameter
  57. in the macro means. forgot what the third parameter for right now. (the
  58. class parameter).
  59.  
  60. It has been years since I have used this macro, and this is from
  61. memeory, but the bottom line is that if you pass the macro the arguments 
  62. it wants correclty then things will work fine. If you do not, then it 
  63. will not work.
  64.  
  65. Nasser
  66.  
  67.  
  68.  
  69.